<script src="/kissy/build/seed-debug.js"></script>
<script src="/kissy/src/package.js"></script>
<script>
    // test es6 generator in nodejs
    var S = KISSY;
    S.use('promise', function (S, Promise) {
        function retPromiseOk(v) {
            var defer = new Promise.Defer();
            setTimeout(function () {
                defer.resolve(v + 1);
            }, 1000);
            return defer.promise;
        }

        function retPromiseError(v) {
            var defer = new Promise.Defer();
            setTimeout(function () {
                defer.reject(v);
            }, 1000);
            return defer.promise;
        }

        retPromiseOk(3).then(function (v) {
            return retPromiseOk(v);
        }).then(function (d) {
                    S.log('success: '+d);
                },function(e){
                    S.log('error: '+e)
                });

        retPromiseOk(3).then(function (v) {
            return retPromiseError('wrong...');
        }).then(function (d) {
                    S.log('success: '+d);
                },function(e){
                    S.log('error: '+e)
                });
    });
</script>